import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * @author Summerday
 */
public class T {

    public static void main(String[] args) {
        String a = "ab";
        String b = "eidboaoo";
        new T().checkInclusion(a, b);
    }
    public boolean checkInclusion(String s1, String s2) {
        int a = s1.length(), b = s2.length();
        if(a > b) return false;
        // 记录每个字符出现的次数
        int[] cnt = new int[128];
        for(int i = 0; i < a; i ++){
            cnt[s1.charAt(i)] ++;
        }
        int j = a - 1, i = 0;
        while(j < b){
            if(check(cnt, i , j, s2)) {
                return true;
            }
            i ++;
            j ++;
        }
        return false;
    }

    boolean check(int[] cnt, int i, int j, String s){
        HashMap<Integer,Integer> map = new HashMap<>();
        ScheduledThreadPoolExecutor scheduledThreadPool = new ScheduledThreadPoolExecutor(10);
        Executors.newScheduledThreadPool(10);

        int[] t = new int[128];
        System.arraycopy(cnt, 0, t, 0, 128);
        // System.out.println(Arrays.toString(t));
        System.out.println(i + " " + j);
        while(i <= j){
            if(-- t[s.charAt(i ++)] < 0){
                return false;
            }
        }
        return true;

    }
}
